﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Web.UI;

namespace htmlRender
{
    class Program
    {
        static void Main(string[] args)
        {
            //htmlWriterWithHtmlTextWriterTag();


            System.IO.TextWriter writer = Console.Out;
            XhtmlTextWriter htmlWriter = new XhtmlTextWriter(writer);

            Hidden hidden = new Hidden();
            hidden.ID = "myData";
            hidden.Value = "Hello, world.";

            Div div = new Div();
            div.Controls.Add(hidden);
            div.RenderControl(htmlWriter);

        }

        private static void htmlWriterWithHtmlTextWriterTag()
        {
            System.IO.TextWriter writer = Console.Out;
            XhtmlTextWriter htmlWriter = new XhtmlTextWriter(writer);

            htmlWriter.RenderBeginTag(HtmlTextWriterTag.Div);
            htmlWriter.AddAttribute(HtmlTextWriterAttribute.Value, "Hello, world.");
            htmlWriter.AddAttribute(HtmlTextWriterAttribute.Type, "hidden");
            htmlWriter.AddAttribute(HtmlTextWriterAttribute.Name, "myData");
            htmlWriter.RenderBeginTag(HtmlTextWriterTag.Input);

            htmlWriter.RenderEndTag();
            htmlWriter.RenderEndTag();
        }

        private static void htmlWriterDemo()
        {
            System.IO.TextWriter writer = Console.Out;
            XhtmlTextWriter htmlWriter = new XhtmlTextWriter(writer);

            htmlWriter.WriteFullBeginTag("div");
            htmlWriter.WriteBeginTag("input");
            htmlWriter.WriteAttribute("type", "hidden");
            htmlWriter.WriteAttribute("name", "myData");
            htmlWriter.WriteAttribute("value", "Hello, world.");
            htmlWriter.Write(HtmlTextWriter.TagRightChar);

            htmlWriter.WriteEndTag("input");
            htmlWriter.WriteEndTag("div");
        }

        private static void TextWriterDemo()
        {
            string div = "<div><input type='hidden' name='myData'/></div>";
            System.IO.TextWriter writer = Console.Out;

            writer.WriteLine(div);
        }
    }
}
